public class QuickSort {
        public static void main(String[] args) {
            int[] arr = {4,6,8,2, 2,2,3,1,9,8,33};
            quick(arr,0,arr.length-1);
            for (int i = 0; i < arr.length; i++) {
                System.out.print(arr[i] + " ");
            }
        }
        private static void quick(int[] arr,int start,int end) {
            if(start >= end) {
                return;
            }
            int right = end;
            int left = start;
            int tmp = arr[start];
            while (left < right) {
                while (left < right && arr[right] >= tmp) {
                    right--;
                }
                while (right > left && arr[left] <= tmp ) {
                    left++;
                }
                if (right > left) {
                    int temp = arr[right];
                    arr[right] = arr[left];
                    arr[left] = temp;
                }
            }
            //基准数和i，j相等的位置交换
            arr[start] = arr[left];
            arr[left] = tmp;
            //左边快排
            quick(arr,start,left-1);
            //右边快排
            quick(arr,right+1,end);
        }
    }
